import request from "@/common/request"
import smCrypto from 'sm-crypto'

const path = '/auth/c/'

export default {
  doLogin(account, password) {
    return request.post(`${path}doLogin`, {
      account: account,
      password: smCrypto.sm2.doEncrypt(password, '04298364ec840088475eae92a591e01284d1abefcda348b47eb324bb521bb03b0b2a5bc393f6b71dabb8f15c99a0050818b56b23f31743b93df9cf8948f15ddb54'),
    }).then(res => {
      uni.setStorageSync("token", res.data);
    });
  },
  doLogout() {
    return request.get(`${path}doLogout`, {}).then(_ => {
      uni.setStorageSync("token", "");
    })
  },
  getLoginUser() {
    return request.get(`${path}getLoginUser`, {});
  }
}
